<?php

// No direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport( 'joomla.application.component.view');


class odudecardViewodudecard extends JView
{
	function display($tpl = null)
	{
			  
			  
 	$model =& $this->getModel();

        $setting = $model->getSetting();
		$cate_detail = $model->getCategory();
		$front = $model->getFront();
		 $random = $model->getGreetingRandom();
		
		//echo $front;
		
        $this->assignRef( 'cate_name',  $cate_detail[0]->name );
		  $this->assignRef( 'cate_banner',  $cate_detail[0]->banner );
		    $this->assignRef( 'cate_bg',  $cate_detail[0]->bg );
			
			$this->assignRef( 'a1',  $setting['a1'] );
			$this->assignRef( 'a2',  $setting['a2'] );
			$this->assignRef( 'a3',  $setting['a3'] );
			$this->assignRef( 'a4',  $setting['a4'] );

		
$cardPerRow=$setting['card_row'];
$cardPerPage=$setting['card_page'];
$rows = $model->getGreeting($cardPerPage);


	$tab="<table width=100% border=0>\n\r";
	$x=0;
	$f=0;
		for( $i=0; $i<count($rows); $i++ )
		{
			$category = $rows[$i];
			if($x==0)
			{
			$tab.="\n\r<tr>";
			$x++;
			}
			
			if($x<=$cardPerRow)
			{
			$id=$category->id;
			$title=$category->title;
			$type=$category->type;
			$file=$category->file;
			$desp=$category->desp;
			$effect=$category->effect;
			$cate=$category->cat;
			$thumb=$category->thumb;
			$file=$category->file;
			
			$tab.='<td valign=top width=114 align=center><div align=center id=card><a href='.JRoute::_('index.php?option=com_odudecard&id='.$id.'&controller=odudecardshow&cate='.$cate).' ><img src="'.JURI::base().'images/stories/ecard/'.$thumb.'" alt="'.$title.'" border=1><br /><br><font size=1 face=arial>'.$title.'</font></a>';
			$tab.="<br> <a rel=\"{handler: 'image', size: {x: 700, y: 400}}\" class=\"modal\" href='".JURI::root()."images/stories/ecard/".$file."'><img src='".JURI::root()."components/com_odudecard/images/zoom.png' alt=".JText::_('ZOOM')." title=".JText::_('ZOOM')." border=0></a>";

            $tab.="</div></td>";
			
			$x++;
			}
			
			if($x==$cardPerRow+1)
			{
			$tab.="</tr>\n\r";
			$x=0;
				
			//$f++;
			
		//	if($f>1)
		//	$i=100;
			}
			
			
		}
$tab.="</table>";

		
		
        $this->assignRef( 'listCard',  $tab );
		

		parent::display($tpl);
	}
	
}
